import fetch from 'common/src/utils/fetch';
import baseUrl from './env';
import UTILS from "common/src/utils/utils";

// 学生考试列表
function getExamList(data) {
    return fetch({
        url: `${baseUrl}/behavior/behaviorstudentexam/getExamList`,
        method: 'post',
        data
    });
}
// 学生考试（随机抽题）
function postStartExam(data) {
    return fetch({
        url: `${baseUrl}/behavior/behaviorstudentexam/startExam`,
        method: 'post',
        data
    });
}
// 提交考试
function submitExamRecordByStudent(data) {
    return fetch({
        url: `${baseUrl}/behavior/behaviorstudentexam/submitExamRecordByStudent`,
        method: 'post',
        data
    });
}
// 重新考试
function startExam(data) {
    return fetch({
        url: `${baseUrl}/behavior/behaviorstudentexam/restartExam`,
        method: 'post',
        data
    });
}
// 查看考试
function queryExamRecord(data) {
    return fetch({
        url: `${baseUrl}/behavior/behaviorstudentexam/queryExamRecord`,
        method: 'post',
        data
    });
}
// 查看考试次序
function getExamNumberByExamId(data) {
    return fetch({
        url: `${baseUrl}/behavior/behaviorstudentexam/getExamNumberByExamId`,
        method: 'post',
        data
    });
}
// 考试查询列表
function getExamQueryPage(data) {
    return fetch({
        url: `${baseUrl}/behavior/examQuery/getExamQueryPage`,
        method: 'post',
        data
    });
}
// 导出
function exports(data) {
    return fetch({
        url: `${baseUrl}/behavior/examQuery/export`,
        method: 'post',
        responseType: 'blob',
        data
    }).then(res => {
        UTILS.downloadFile(res, '考试查询.xlsx', 'application/vnd.ms-excel;charset=utf-8')
    })
}
// 查看学生考试记录下拉
function getStuExamList(data) {
    return fetch({
        url: `${baseUrl}/behavior/examQuery/getStuExamList?studentId=${data.studentId}&examId=${data.examId}`,
        method: 'get',
        data
    });
}
// 考试统计导出
function statisticExport(data) {
    return fetch({
        url: `${baseUrl}/behavior/examQuery/statisticExport`,
        method: 'post',
        responseType: 'blob',
        data
    }).then(res => {
        UTILS.downloadFile(res, '考试统计.xlsx', 'application/vnd.ms-excel;charset=utf-8')
    })
}
// 考试统计查询
function statisticQuery(data) {
    return fetch({
        url: `${baseUrl}/behavior/examQuery/statisticQuery`,
        method: 'post',
        data
    });
}
export default {
    'getExamList': getExamList,
    'postStartExam': postStartExam,
    'submitExamRecordByStudent': submitExamRecordByStudent,
    'startExam': startExam,
    'queryExamRecord': queryExamRecord,
    'getExamNumberByExamId': getExamNumberByExamId,
    'getExamQueryPage': getExamQueryPage,
    'exports': exports,
    'getStuExamList': getStuExamList,
    'statisticExport': statisticExport,
    'statisticQuery': statisticQuery
};
